// import com.alibaba.druid.sql.ast.SQLName;
// import com.alibaba.druid.sql.dialect.oracle.ast.OracleSQLObjectImpl;
// import com.alibaba.druid.sql.dialect.oracle.visitor.OracleASTVisitor;

// import java.util.ArrayList;
// import java.util.List;

#include "PartitionExtensionClause.h"
#include "../../../../ast/SQLName.h"
#include "../../visitor/OracleASTVisitor.h"
#include "../../../../../utils/listTran.h"

PartitionExtensionClause::PartitionExtensionClause()
{
  target = std::make_shared<std::list<SQLName_ptr>>();
}
BOOL_ptr PartitionExtensionClause::isSubPartition()
{
  return subPartition;
}

void PartitionExtensionClause::setSubPartition(BOOL_ptr subPartition)
{
  this->subPartition = subPartition;
}

SQLName_ptr PartitionExtensionClause::getPartition()
{
  return partition;
}

void PartitionExtensionClause::setPartition(SQLName_ptr partition)
{
  this->partition = partition;
}

SQLName_list_ptr PartitionExtensionClause::getFor()
{
  return target;
}

// @Override
void PartitionExtensionClause::accept0(OracleASTVisitor_ptr visitor)
{
  if (visitor->visit(SharedObject(PartitionExtensionClause)))
  {
    acceptChild(visitor, partition);
    SQLObject_list_ptr tmp = ListTran::tran_class<SQLName, SQLObject>(target);
    acceptChild(visitor, tmp);
  }
  visitor->endVisit(SharedObject(PartitionExtensionClause));
}

SQLObject_ptr PartitionExtensionClause::clone()
{
  SQLObject_ptr clone_tmp = std::shared_ptr<PartitionExtensionClause>(new PartitionExtensionClause());
  std::shared_ptr<PartitionExtensionClause> x = std::dynamic_pointer_cast<PartitionExtensionClause>(clone_tmp);
  // PartitionExtensionClause x = new PartitionExtensionClause();

  x->subPartition = subPartition;
  if (partition != nullptr)
  {
    x->setPartition(std::dynamic_pointer_cast<SQLName>(partition->clone()));
  }

  for (SQLName_ptr item : *target)
  {
    SQLName_ptr item1 = std::dynamic_pointer_cast<SQLName>(item->clone());
    item1->setParent(x);
    x->target->push_back(item1);
  }

  return x;
}
